import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardDemo {
    String[] suits = {"♥","♦","♠","♣"};

    public List<Card> buyCard(){
        List<Card> cards = new ArrayList<Card>();
        for (int i = 1; i <= 13; i++) {
            for (String suit : suits) {
                Card card = new Card(suit, i);
                cards.add(card);
            }
        }
        return cards;
    }

    public void shuffle(List<Card> cards){
        Random random = new Random();
        for(int i = cards.size() - 1; i > 0; i--){
            int index = random.nextInt(i);
            swap(cards, i, index);
        }
    }

    public void swap(List<Card> cards, int i, int j){
        Card temp = cards.get(i);
        cards.set(i, cards.get(j));
        cards.set(j, temp);
    }

    public List<List<Card>> play(List<Card> cards){
        List<Card> hand0 = new ArrayList<>();
        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();

        List<List<Card>> hands = new ArrayList<>();
        hands.add(hand0);
        hands.add(hand1);
        hands.add(hand2);

        for(int i = 0; i < 5; i++){
            for(int j = 0; j < 3; j++){
                Card card = cards.remove(0);
                hands.get(j).add(card);
            }
        }
        return hands;
    }
}
